﻿using System;
using YAF.Classes.Core;

namespace YAF.Modules
{
    [YafModule("Provider Settings Module", "Tiny Gecko", 1)]
    public class ProviderSettingsModule : IBaseModule
    {
        public YafContext PageContext
        {
            get
            {
                return YafContext.Current;
            }
        }

        #region IBaseModule Members
        public object ForumControlObj
        {
            get;
            set;
        }

        public void Init()
        {
            YafContext.Current.PageInit += Current_PageInit;
        }

        public void Dispose()
        {
 
        }
        #endregion

        private void Current_PageInit(object sender, EventArgs e)
        {
            if (!PageContext.CurrentMembership.ApplicationName.Equals(PageContext.BoardSettings.MembershipAppName))
            {
                PageContext.CurrentMembership.ApplicationName = PageContext.BoardSettings.MembershipAppName;
            }
            if (!PageContext.CurrentRoles.ApplicationName.Equals(PageContext.BoardSettings.RolesAppName))
            {
                PageContext.CurrentRoles.ApplicationName = PageContext.BoardSettings.RolesAppName;
            }
        }
    }
}
